<template>
	<u-tabbar :value="valueModel" :fixed="true" @change="changeRouter" :placeholder="true" z-index='9999'
		:safeAreaInsetBottom="true">
		<u-tabbar-item :badge="index==0?'3':null" :text="item.text" :icon="item.iconPath"
			v-for="(item,index) in vuex_tabbar" :key='index'></u-tabbar-item>
	</u-tabbar>
</template>

<script>
	import {
		mapState
	} from 'vuex' //引入mapGetters
	export default {
		name: "u-tabbar-own",
		data() {
			return {};
		},
		props: {
			valueModel: {
				type: Number,
				default: 0
			}
		},
		created() {
			// 是否隐藏原生tabbar
			uni.hideTabBar();
		},
		mounted() {


		},
		computed: {
			...mapState({
				vuex_tabbar: state => state.vuex_tabbar,
			})
		},
		methods: {
			changeRouter(e) {

				if (e == 0) {
					if (this.$store.state.vuex_tabbar[0].text == '待办') {
						uni.switchTab({
							url: `/pages/backlog/backlog`
						});
					} else {
						uni.setTabBarItem({
						  index: 0,
						  text: "",
						  selectedIconPath: '/pages/fieldStatistics/fieldStatistics'
						})
						uni.switchTab({
							url: `/pages/fieldStatistics/fieldStatistics`
						});
					}

				} else if (e == 1) {
					uni.switchTab({
						url: `/pages/client/client`
					});
				} else if (e == 2) {
					uni.switchTab({
						url: `/pages/workbench/workbench`
					});
				} else if (e == 3) {
					uni.switchTab({
						url: `/pages/resource/resource`
					});
				} else if (e == 4) {
					uni.switchTab({
						url: `/pages/my/my`
					});
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	.f-fixed {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 1000;
	}
</style>
